﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using QLT_BLL;
using QLT_Public;

namespace GiaoDien
{
    public partial class uc_TKNhanVien : DevExpress.XtraEditors.XtraUserControl
    {
        public uc_TKNhanVien()
        {
            InitializeComponent();
        }

        NhanVien_BLL nhanvien_bll = new NhanVien_BLL();
       private void btnTimKiem_Click(object sender, EventArgs e)
        {
            NhanVien_Public nv = new NhanVien_Public();
            if (txtMaNV.Text != "")
            {
                nv.MaNV =Convert.ToInt32( txtMaNV.Text);
                gridControl1.DataSource = nhanvien_bll.TimKiem_MaNV(nv);

            }
            if (txtHoTen.Text != "")
            {
                nv.HoTen = txtHoTen.Text;
                gridControl1.DataSource = nhanvien_bll.TimKiem_HoTen(nv);
            }
            if (txtMaNV.Text != "" && txtHoTen.Text != "")
            {
                nv.MaNQ = Convert.ToInt32(txtMaNV.Text);
                nv.HoTen = txtHoTen.Text;
                gridControl1.DataSource = nhanvien_bll.TimKiem_MaNV_HoTen(nv, nv);
            }
        }

       private void uc_TKNhanVien_Load(object sender, EventArgs e)
       {
           gridControl1.DataSource = nhanvien_bll.Load_TimKiem_NhanVien();
       }
       public void Huy_Text(Control ctr)
       {
           if (ctr is TextBox || ctr is TextEdit)
           {
               ctr.Text = string.Empty;
           }
           foreach (Control i in ctr.Controls)
           {
               Huy_Text(i);
           }
       }
       private void btnLamMoi_Click(object sender, EventArgs e)
       {
           Huy_Text(this);
           uc_TKNhanVien_Load(sender, e);
       }

       private void txtMaNV_KeyPress(object sender, KeyPressEventArgs e)
       {
           if (!Char.IsDigit(e.KeyChar) && !Char.IsControl(e.KeyChar))
               e.Handled = true;
       }

    }
}
